<template>
	<view>
		<view class="list-one">
			<view class="list-one-item" v-for="(item,index) in list" :key="index" @click="tolist(item)">
				<view class="live-image">
					<image class="image" :src="item.cover_img || item.pic_url" mode="aspectFill"></image>
					<!-- <view v-if="item.live_status === 101" class="tag-box tag-box-3">
						<view class="text">
							<image class="live-icon" src="/static/image/icon/liveing.png"></image>
							<span>{{item.status_text}}</span>
						</view>
					</view> -->
					<!--预告-->
					<view v-if="item.status == 1" class="tag-box tag-box-1">
						<view class="text">
							<view class="round"></view>
							<span>抢货预告</span>
						</view>
						<view class="text-time">{{item.start_at}}-{{item.end_at}}</view>
					</view>
					<view v-else-if="item.status == 2" class="tag-box tag-box-2">
						<view class="text">
							<view class="round"></view>
							<span>正在抢货</span>
						</view>
					</view>
					<view v-else class="tag-box tag-box-3">
						<view class="text">
							<view class="round"></view>
							<span>珠宝介绍回放</span>
						</view>
					</view>
				</view>
				<view class="u-line-2">
					{{item.title}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	let loadcom = false
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				page_count: 1,
			}
		},
		onLoad() {
			this.loadentlist(this.catid)
		},
		onReachBottom() {
			if (this.page < this.page_count && loadcom) {
				this.page++
				this.appPort()
			}
		},
		methods: {
			async appPort() {
				// 9.9修
				loadcom = false
				const res = await this.$request({
					url: this.$api.navs.mersq,
					data: {
						page: this.page,
						status: 1,
						limit: 10,
						// 10.27 添加好货快抢的标识
						pid: 1
					}
				});
				if (res.code === 0) {
					loadcom = true
					let listvideo = []
					let status = ''
					this.page_count = res.data.pagination.page_count;
					listvideo = res.data.list
					listvideo = listvideo.filter(response => {
						let nes = response
						status = this.listJump(nes.id, nes.goodslist, nes.start_at, nes.end_at)
						nes.start_at = nes.start_at.substr(11, 5)
						nes.end_at = nes.end_at.substr(11, 5)
						this.$set(nes, 'status', status);
						this.$set(nes, 'start_at', nes.start_at);
						this.$set(nes, 'end_at', nes.end_at);
						return nes
					})
					this.list = this.list.concat(listvideo)
					uni.stopPullDownRefresh()
				} else {
					uni.stopPullDownRefresh()
					uni.showModal({
						title: '提示',
						content: res.msg,
					})
				}
			},
			listJump(id, list, stime, etime) {
				// 当前时间
				let catime = new Date()
				// 开始时间
				let satime = new Date(stime.replaceAll('-', '/'))
				// 结束时间
				let eatime = new Date(etime.replaceAll('-', '/'))
				if (satime > catime) {
					this.sup_status = 1
				} else if (satime <= catime && catime < eatime) {
					let salist = []
					salist = list.filter((itm, index) => {
						return itm.goods_stock != 0
					})
					if (salist.length == 0) {
						this.sup_status = 3
					} else {
						this.sup_status = 2
					}
				} else if (catime >= eatime) {
					this.sup_status = 3
				}
				return this.sup_status
				// return this.sup_status
			},
		}
	}
</script>

<style>

</style>
